﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BrokerBase.Lib.Policy;

namespace Broker.View.PolicyView
{
    /// <summary>
    /// DutyDetailPage.xaml 的交互逻辑
    /// </summary>
    public partial class DutyDetailPage :UserControl
    {
        private IPolicyActing pa;
        
        private DutyActingForm dutyActingFrm;
        private IPolicyPeriodActing ppa;

        public DutyDetailPage()
            :base()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(DutyDetailPage_Loaded);
            
        }

        void dutyActingFrm_SchemePeriodActingChanged(ISchemePeriodActing spa)
        {
            this.ppa = spa.PolicyPeriodActings.FirstOrDefault(p => p.PolicyActing.Policy.Product.Id == pa.Policy.Product.Id);

            this.DataContext = null;
            this.DataContext = ppa;
        }

        public DutyDetailPage(DutyActingForm frm, IPolicyActing pa)
            : this()
        {
            this.dutyActingFrm = frm;
            this.pa = pa;
            dutyActingFrm.SchemePeriodActingChanged += new SchemePeriodActingChangedHandler(dutyActingFrm_SchemePeriodActingChanged);
        }

        void DutyDetailPage_Loaded(object sender, RoutedEventArgs e)
        {
            
        }
    }
}
